def py2topy3(python_file):
    import os
    os.system(r'python C:\Users\yuexiang\Anaconda3\pkgs\python-3.6.2-h6679aeb_11\Tools\scripts\2to3.py -w {}'.format(python_file))

from os import listdir
from os.path import isfile, join, isdir
def getAllFilesRecursive(root):
    files = [join(root, f) for f in listdir(root) if isfile(join(root, f))]
    dirs = [d for d in listdir(root) if isdir(join(root, d))]
    for d in dirs:
        files_in_d = getAllFilesRecursive(join(root, d))
        if files_in_d:
            for f in files_in_d:
                files.append(join(root, f))
    return files

if __name__ == "__main__":
    import argparse

    parser = argparse.ArgumentParser(description="convert py2 to py3 using 2to3.py")
    parser.add_argument("dir", help="directory of your py2 project")
    args = parser.parse_args()

    dir = args.dir

    files = [file for file in getAllFilesRecursive(dir) if file.endswith(".py")]
    for file in files:
        py2topy3(file)
